//
//  ChoseSeatViewController.m
//  PeopleStreet
//
//  Created by 辰领科技 on 16/3/24.
//  Copyright © 2016年 yuf. All rights reserved.
//

#import "ChoseSeatViewController.h"
#import "ChoseSateView.h"

@interface ChoseSeatViewController ()
@property (strong, nonatomic) IBOutlet UIView *navView;
@property (strong, nonatomic) IBOutlet UIScrollView *scroView;
@property (strong, nonatomic) IBOutlet UILabel *movieName;
@property (strong, nonatomic) IBOutlet UILabel *movieInfo;
@property (strong, nonatomic) IBOutlet UILabel *seatNumber;
@property (strong, nonatomic) IBOutlet UIButton *choseSeatButton;
@property(nonatomic,strong)NSMutableArray * chosenSeatArray;
@end

@implementation ChoseSeatViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    _chosenSeatArray = [NSMutableArray array];
    [self initViewLayout];
}

- (void)initViewLayout{
    [self adaptiveViewLayout:self.view];
    [self adaptiveViewLayout:self.navView];
    [self adaptiveViewLayout:self.scroView];
    _choseSeatButton.layer.cornerRadius = 3*VerticalRatio();
    
    NSArray * array = @[@[@0,@0,@0,@0,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1],
                          @[@0,@0,@0,@0,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1],
                          @[@0,@0,@0,@0,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1],
                          @[@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1],
                          @[@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1],
                          @[@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1],
                          @[@1,@1,@1,@1,@1,@1,@2,@1,@2,@1,@1,@1,@1,@1,@1,@1],
                          @[@1,@1,@1,@1,@1,@2,@2,@2,@2,@2,@1,@1,@1,@1,@1,@1],
                          @[@1,@1,@1,@1,@2,@2,@2,@2,@2,@2,@2,@1,@1,@1,@1,@1],
                          @[@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1],
                          @[@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1],
                         @[@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1,@1]];
    
    ChoseSateView * seatView = [[ChoseSateView alloc]initWithFrame:flexibleFrame(CGRectMake(0, 95, 320, 355), YES) Title:@"4号厅银幕中央"  SateLayoutArray:array complect:^(NSMutableArray *chosenArray) {
        _chosenSeatArray = chosenArray ;
        if (chosenArray.count>0) {
            [_choseSeatButton setTitle:@"确认座位" forState:UIControlStateNormal];
            _choseSeatButton.backgroundColor = [UIColor colorWithRed:0.980 green:0.804 blue:0.204 alpha:1.000];
            _choseSeatButton.enabled = YES;
            _seatNumber.textColor = [UIColor colorWithWhite:0.635 alpha:1.000];
            NSString * countPrice = [NSString stringWithFormat:@"￥%ld ",chosenArray.count*35];
            NSString * price = [NSString stringWithFormat:@"(￥35x%ld)",chosenArray.count];
            NSMutableAttributedString * str = [[NSMutableAttributedString alloc]initWithString:[countPrice stringByAppendingString:price]];
            [str addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:0.980 green:0.624 blue:0.000 alpha:1.000] range:NSMakeRange(0, countPrice.length)];
            [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:20*VerticalTexeRatio()] range:NSMakeRange(0, countPrice.length)];
            _seatNumber.attributedText = str;
            
        }else{
            _choseSeatButton.enabled = NO;
            [_choseSeatButton setTitle:@"请先选座位" forState:UIControlStateNormal];
            _choseSeatButton.backgroundColor = [UIColor colorWithWhite:0.875 alpha:1.000];
            _seatNumber.text = @"一次最多选4个座位";
            _seatNumber.textColor = [UIColor colorWithWhite:0.494 alpha:1.000];
            _seatNumber.font = [UIFont systemFontOfSize:15*VerticalTexeRatio()];
        }
        
        }];
    [_scroView addSubview:seatView];
}

- (IBAction)back:(id)sender {
    [self.navigationController  popViewControllerAnimated:YES];
}

#pragma mark == 选定座位
- (IBAction)choseHandel:(id)sender {
    UIStoryboard *secondStroyBoard=[UIStoryboard storyboardWithName:@"HomeStoryboard" bundle:nil];
    UIViewController *page = [secondStroyBoard instantiateViewControllerWithIdentifier:@"PaySeat"];
    [self.navigationController   pushViewController:page animated:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
@end
